<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<!-- <meta http-equiv="refresh" content="2" /> -->
	<title>上传图片共享</title>
	<!--[if lt IE 9]>
		<script src="<%=basePath %>js/ie9.js"></script>
	<![endif]-->
	<link rel="icon" href="<%=basePath %>images/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="<%=basePath %>images/favicon.ico" type="image/x-icon" />
	<script src="<%=basePath %>js/jquery-1.4.2.min.js"></script>
	<script src="<%=basePath %>js/sign-up.js"></script>
	<script type="text/javascript" src="<%=basePath %>js/jquery.uploadify.v2.1.4.min.js"></script>
	<script type="text/javascript" src="<%=basePath %>js/swfobject.js"></script>
	<link rel="stylesheet" type="text/css" href="<%=basePath %>css/upload.css" />
	<link type="text/css" rel="stylesheet" href="<%=basePath %>css/uploadify.css"/>
	<script type="text/javascript" src="<%=basePath %>js/jquery.boxy.js"></script>
	<link type="text/css" rel="stylesheet" href="<%=basePath %>css/boxy.css"/>
	<script type="text/javascript">
$(function() {
	var id = $("#userId").val();
	var album = $("#userAlbum").val();
	var type = $("#type").val();
	$("#type").change(function() {
		type = $("#type").val();
	});
 	$('#up').uploadify ({
        'uploader'       : '${pageContext.request.contextPath }/js/uploadify.swf',
        'script'         : 'pictureAction!upload',
        'cancelImg'      : '${pageContext.request.contextPath }/images/cancel.png',
        'scriptData'     : {"picture.user.id": id, "album": album, "type": type}, 
        'method'         : 'GET',  
        'fileDataName'   : 'up',
        'auto'           :  false,
        'queueID'        : 'fileQueue', 
        'folder'         : '/photos',
        'fileExt'        : '*.png;*.gif;*.jpg;*.bmp;*.jpeg',  
        'fileDesc'       : '图片文件(*.png;*.gif;*.jpg;*.bmp;*.jpeg)', 
        'queueSizeLimit' : 5,
        'sizeLimit'      : 5242880,
        'multi'          : true,
        'simUploadLimit' : 1,
        onAllComplete    : function(event,queueID,fileObj,response,data) {
        	$("#loading").hide();
        	Boxy.confirm("<label style='font-size: 12px;'>图片上传成功，继续上传请点击取消。查看图片请点击确定</label>", function() { window.location.href = "pictureAction!findForPage?picture.user.id=" + id + "&page=" + 1; });
 	 	}, 
 		'buttonText'     : "Select photos", 
 		onSelectOnce     : function() {
 	 		$("#loading").show();
 	 	}
    });
});
</script>
</head>
<body>
<c:if test="${sessionScope.loginUser == null}">
	<script type="text/javascript">
		window.location.href = "../jsp/login.jsp";
	</script>
</c:if>
<c:if test="${sessionScope.loginUser != null}">
	<div id="header">
		<div class="header-content">
			<h1 class="logo">
				<a href="<%=basePath %>jsp/index.jsp">photobucket</a>
			</h1>
			<a href="<%=basePath %>jsp/upload.jsp" class="nav-upload">上传</a>
			<form action="pictureAction!findByKeyWord" class="search" method="post">
				<div class="search-group">
					<input type="text" name="keyWord" class="field style" value="用户名、图片类别"/>
					<input type="hidden" name="page" value="1"/>
					<input type="submit" title="Submit" value="" class="submit" />
				</div>
			</form>
			<div class="login">
				<img src="<%=basePath %>${sessionScope.loginUser.photoSticker}" width="30" height="30"/>
				<a href="#">${sessionScope.loginUser.userName }</a>
			</div>
		</div>
	</div> <!-- header -->
	<div class="content">
		<div class="content2">
			<div class="title">
				<h2>图片共享</h2>
			</div>
			<div class="main">
				<div id="description">选择图片上传，支持*.png;*.gif;*.jpg;*.bmp;*.jpeg格式的图片文件，最多可以同时上传5张图片文件，图片大小最大为5M</div>
				<div class="show-user">
					<img src="<%=basePath %>${sessionScope.loginUser.photoSticker }" alt="${sessionScope.loginUser.photoSticker }" width="120px" height="120px"/>
				</div>
				<div class="tabs" id="tabs">
					<div id="tab-prototype">
						<input type="file" id="up" name="up" />
						<em>
						<label>请选择所上传的图片类别</label>
						<select name="type" id="type">
							<option value="0">生活</option>
							<option value="1">人物</option>
							<option value="2">风景</option>
							<option value="3">时尚</option>
							<option value="4">其他</option>
						</select>
					</em>
						<div id="fileQueue" style="width: 440px;height: 310px; border: 1px solid #eee;"></div>
					</div>
				</div>
				<div class="uploadBtn">
					<input type="hidden" value="${sessionScope.loginUser.id }" id="userId" name="user.id" />
					<input type="hidden" value="${sessionScope.loginUser.album }" id="userAlbum" name="user.album" />
					<input type="button" id="upload" onclick="javascript:$('#up').uploadifySettings('scriptData',{'picture.user.id': $('#userId').val(), 'album': $('#userAlbum').val(), 'type': $('#type').val()});$('#up').uploadifyUpload();" value="开始上传"/>
					<img src="<%=basePath %>images/loading.gif" id="loading" style="display: none;"/>
				</div>
			</div> <!-- main -->
			<div class="categories">
				<h5>便笺</h5>
				<ul>
					<li><a href="userAction!findById?user.id=${sessionScope.loginUser.id }">个人信息</a></li>
					<li><a href="<%=basePath %>jsp/modifysticker.jsp">修改头像</a></li>
					<li><a href="pictureAction!findForPage?picture.user.id=${sessionScope.loginUser.id }&page=1">个人图片</a></li>
					<li><a href="pictureAction!findAll?page=1">所有图片</a></li>
					<li><a href="userAction!logout">安全注销</a></li>
				</ul>
			</div> <!-- categories -->
			<div class="whatisnew">
				<div class="info">
					<h5>Edit Your Photos</h5>
					<p>Create all kinds of amazing special effects with our free, built-in image editor. Create color splash, cartoon, pop art effects, and much more!</p>
					<a href="#">Check it out</a>
				</div>
			</div> <!-- whatisnew --></div>
			<div class="toolbar">
			</div>
	</div> <!-- contetn -->
	<div class="footer">
		<div class="footer-content">
			<p>Copyright 2012 Sharelife Corporation.  All rights reserved.  |   <a href="#">Privacy policy</a>  |   <a href="#">Terms of use</a>  |   <a href="#">Site map</a></p>
		</div>
	</div>
</c:if>
</body>
</html>
